Repository navigation
chore: improve workflows - #732
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded@AmanVarshney01 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 52 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds a PR preview GitHub Actions workflow that waits for tests, publishes preview NPM packages, and comments on PRs; restructures the release workflow with gated tests, semver checks, and conditional tagging/publishing; simplifies test workflow to Bun; adds a cleanup script and package script for preview dist-tags. Changes
Sequence Diagram(s)sequenceDiagram
participant PR as Pull Request
participant GH as GitHub Actions
participant Checks as GitHub Checks API
participant NPM as NPM Registry
participant Comment as PR Comments
PR->>GH: 'preview' label applied
GH->>GH: Start wait-for-tests job
loop Poll (every ~30s, up to 10min)
GH->>Checks: Query checks for PR head SHA ("Test Suite")
Checks-->>GH: status (queued/running/conclusion)
end
alt All tests conclude success
GH->>GH: tests-passed = true
GH->>GH: Start publish-preview job
GH->>NPM: Compute preview versions (base + pr# + sha)
GH->>NPM: Publish packages with tag "pr<PR number>"
NPM-->>GH: confirm publishes
GH->>Comment: Post or update preview summary with versions & install instructions
else Tests fail or timeout
GH->>GH: tests-passed = false
GH->>Comment: Post failure message
GH->>PR: Remove 'preview' label
end
sequenceDiagram
participant Dev as Dev (push)
participant GH as GitHub Actions
participant Workspace as CI Workspace
participant NPM as NPM Registry
participant Git as Git
participant Release as GitHub Release
participant Summary as Step Summary
Dev->>GH: Push to main with chore(release): VERSION
GH->>GH: Start Test Suite job
GH->>Workspace: Checkout, setup Bun, build types, build & test CLI
GH->>NPM: Query if VERSION exists
alt VERSION not found
GH->>Workspace: Update package versions via jq
GH->>Workspace: Build packages
GH->>NPM: Publish packages (`@types`, create-bts, `@cli`) at VERSION
NPM-->>GH: publish confirmations
GH->>Git: Create and push tag vVERSION
GH->>Release: Create GitHub Release for vVERSION
GH->>Summary: Write release summary with links
else VERSION already exists
GH->>Summary: Skip publishing, log existing version
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
scripts/cleanup-previews.ts (2)
6-8: Use type alias instead of interface.Per coding guidelines, prefer TypeScript type aliases over interface declarations.
-interface DistTags { - [tag: string]: string; -} +type DistTags = { + [tag: string]: string; +};
49-51: Consider logging the actual error for debugging purposes.The catch block swallows the error details. While the warning message is helpful, logging the error would aid debugging when tag fetching fails unexpectedly.
} catch (err) { - console.warn(`Failed to fetch tags for ${pkg}`); + console.warn(`Failed to fetch tags for ${pkg}:`, err instanceof Error ? err.message : err); }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/workflows/pr-preview.yaml(1 hunks).github/workflows/release.yaml(2 hunks).github/workflows/test.yaml(1 hunks)package.json(1 hunks)scripts/cleanup-previews.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)
Define functions using the standard function declaration syntax, not arrow functions
Files:
scripts/cleanup-previews.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)
**/*.{ts,tsx}: Use TypeScript type aliases instead of interface declarations
Do not use explicit return types
Files:
scripts/cleanup-previews.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
**/*.{ts,tsx,js,jsx}: Usebun <file>instead ofnode <file>orts-node <file>for running TypeScript/JavaScript files
Bun automatically loads .env files, so don't use the dotenv package
UseBun.serve()which supports WebSockets, HTTPS, and routes instead ofexpress
Usebun:sqlitemodule for SQLite instead ofbetter-sqlite3
UseBun.redisfor Redis instead ofioredis
UseBun.sqlfor Postgres instead ofpgorpostgres.js
Use built-inWebSocketinstead of thewspackage
PreferBun.fileovernode:fsreadFile/writeFile methods
UseBun.$template literal syntax instead ofexecafor shell command execution
Import .css files directly in TypeScript/JavaScript files; Bun's CSS bundler will handle bundling
Run server withbun --hot <file>to enable hot reloading during development
Files:
scripts/cleanup-previews.ts
**/*.{ts,tsx,js,jsx,css}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Use
bun build <file>instead ofwebpackoresbuildfor bundling TypeScript, JavaScript, and CSS files
Files:
scripts/cleanup-previews.ts
**/*.{html,tsx,ts,jsx,js}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Use HTML imports with
Bun.serve()for frontend instead of Vite
Files:
scripts/cleanup-previews.ts
package.json
📄 CodeRabbit inference engine (.cursor/rules/convex_rules.mdc)
Always add @types/node to your package.json when using any Node.js built-in modules
Use
bun run <script>instead ofnpm run <script>,yarn run <script>, orpnpm run <script>
Files:
package.json
{package.json,bun.lockb}
📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Use
bun installinstead ofnpm install,yarn install, orpnpm install
Files:
package.json
🧠 Learnings (10)
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to package.json : Use `bun run <script>` instead of `npm run <script>`, `yarn run <script>`, or `pnpm run <script>`
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to {package.json,bun.lockb} : Use `bun install` instead of `npm install`, `yarn install`, or `pnpm install`
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.{ts,tsx,js,jsx,css} : Use `bun build <file>` instead of `webpack` or `esbuild` for bundling TypeScript, JavaScript, and CSS files
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `bun <file>` instead of `node <file>` or `ts-node <file>` for running TypeScript/JavaScript files
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `Bun.$` template literal syntax instead of `execa` for shell command execution
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Run server with `bun --hot <file>` to enable hot reloading during development
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use `bun:test` module with `test` and `expect` functions for writing tests
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `bun:sqlite` module for SQLite instead of `better-sqlite3`
Applied to files:
package.json
📚 Learning: 2025-12-03T07:48:26.419Z
Learnt from: CR
Repo: AmanVarshney01/create-better-t-stack PR: 0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-12-03T07:48:26.419Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `Bun.sql` for Postgres instead of `pg` or `postgres.js`
Applied to files:
package.json
🔇 Additional comments (13)
.github/workflows/test.yaml (2)
10-12: Well-structured concurrency configuration.The concurrency group using
github.head_ref || github.refcorrectly handles both PR and push events, preventing redundant test runs when new commits are pushed.
40-45: Simplified build and test step looks good.Combining the build and test into a single CLI-focused step (
bun run build && bun run test:ci) streamlines the workflow. TheAGENT: 1andBTS_TELEMETRY: 0environment variables are correctly set.scripts/cleanup-previews.ts (1)
116-156: Cleanup logic is well-structured with appropriate error handling.The
cleanupPRfunction correctly handles dry-run mode, gracefully handles missing versions, and provides clear status output for each package. The per-operation try-catch blocks ensure one failure doesn't stop cleanup of other packages..github/workflows/release.yaml (4)
13-15: Correct concurrency strategy for releases.Setting
cancel-in-progress: falseprevents partial releases by ensuring in-progress release jobs complete before new ones start.
75-81: Good version format validation.The semver regex validation prevents malformed versions from being published. This is a useful safeguard.
83-93: Idempotency check prevents duplicate releases.Checking if the version already exists on NPM before proceeding prevents accidental republishing and makes the workflow idempotent.
149-154: Verify the caret prefix for types dependency is intentional.The types dependency uses
^$VERSION(caret range), while thecreate-btspackage on line 168 uses the same pattern. This allows minor version updates, which may be intentional for flexibility, but differs from how preview versions pin exact versions.package.json (1)
19-19: Script entry follows established conventions.The new
cleanup-previewsscript correctly usesbun runto execute the TypeScript file, consistent with other scripts in this monorepo and the coding guidelines..github/workflows/pr-preview.yaml (5)
3-5: Security note:pull_request_targetwith PR code checkout.Using
pull_request_targetwith checkout ofgithub.event.pull_request.head.sha(line 89) allows publishing previews from fork PRs. This is the correct pattern, but ensure theNPM_TOKENsecret has appropriate scope limitations since this workflow can execute code from external contributors.The
previewlabel requirement (line 20) provides a manual gate, which is good. Consider documenting this security model for maintainers.
34-37: Polling configuration is reasonable.60 attempts × 10 seconds = 10 minutes timeout. This should be sufficient for most test runs given the 15-minute timeout in the test workflow.
102-117: Preview version generation is well-designed.The version format
{BASE_VERSION}-pr{PR_NUMBER}.{COMMIT_SHA}provides traceability to both the PR and specific commit, and thepr{NUMBER}tag allows easy installation of the latest preview for a given PR.
133-136: Pinning types dependency to exact preview version.Unlike the release workflow (which uses
^$VERSION), the preview workflow pins the types dependency to the exact preview version. This is appropriate for previews where all packages should use the same preview build.
241-254: Good practice: Automatic label removal on failure.Removing the
previewlabel when tests fail provides clear feedback and prevents confusion about preview status. The try-catch handles the case where the label was already removed.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/release.yaml (1)
29-32: Consider Git user configuration consistency.The test job uses
github-actions[bot]credentials (lines 30-32), while tag creation uses personal credentials (lines 96-97). This inconsistency might cause confusion in Git history.For consistency, consider using the same Git user throughout:
VERSION="${{ steps.version.outputs.version }}" - git config --local user.email "amanvarshney.work@gmail.com" - git config --local user.name "Aman Varshney" + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]"Also applies to: 96-97
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/release.yaml(2 hunks).github/workflows/test.yaml(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/test.yaml
🔇 Additional comments (5)
.github/workflows/release.yaml (5)
3-15: LGTM! Appropriate trigger and concurrency configuration.The push-to-main trigger and concurrency settings are well-suited for a release workflow, preventing concurrent releases while allowing multiple PRs to queue.
92-103: Verify error handling for tag creation.The tag creation includes a defensive check for tag existence, but there's no explicit error handling if
git push --tagsfails (e.g., due to network issues or permission problems).Is it acceptable for the workflow to fail silently if tag pushing fails, or should there be explicit error handling and notification?
160-165: LGTM! create-bts package version update is correct.The
jqcommand properly updates both the package version and the dependency oncreate-better-t-stack, ensuring consistency.
183-195: LGTM! Well-formatted release summary.The release summary provides clear links to all published packages and the GitHub release, making it easy to verify the release.
18-22: This review concern is unfounded. Tests run on all commits to main through the separatetest.yamlworkflow, which triggers unconditionally on pushes to main. Therelease.yamlworkflow is intentionally specialized for release commits only (those starting withchore(release):), providing proper separation of concerns. Non-release commits skip the release workflow's test job by design, not by oversight, since they're already tested by the dedicated CI workflow.
| - name: Validate version format | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: Invalid version format '$VERSION'. Expected semver (x.y.z)" | ||
| exit 1 | ||
| fi | ||
|
|
There was a problem hiding this comment.
Semver validation doesn't support pre-release versions.
The regex ^[0-9]+\.[0-9]+\.[0-9]+$ only validates basic semver format (x.y.z) and will reject pre-release versions like 1.0.0-beta.1 or versions with build metadata.
If pre-release versions are needed in the future, update the regex to:
- if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Validate version format | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Error: Invalid version format '$VERSION'. Expected semver (x.y.z)" | |
| exit 1 | |
| fi | |
| - name: Validate version format | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then | |
| echo "Error: Invalid version format '$VERSION'. Expected semver (x.y.z)" | |
| exit 1 | |
| fi | |
🤖 Prompt for AI Agents
In .github/workflows/release.yaml around lines 72-79, the current regex only
allows x.y.z and will reject valid semver pre-release and build metadata (e.g.,
1.0.0-beta.1); replace the simple regex check with a proper semver-aware
validation—either swap the pattern for a full semver-spec-compliant regex
(allowing optional prerelease and build metadata) or call a semantic versioning
validator (e.g., the well-known semver library) to validate VERSION so
pre-release and build metadata versions are accepted.
| - name: Update CLI types dependency and version | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: | | ||
| VERSION=${{ steps.version.outputs.version }} | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| cd apps/cli | ||
| bun run node -e "const pkg=require('./package.json');pkg.dependencies['@better-t-stack/types']='^$VERSION';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2)+'\n')" | ||
| jq --arg v "^$VERSION" '.dependencies["@better-t-stack/types"] = $v' package.json > tmp.json && mv tmp.json package.json |
There was a problem hiding this comment.
Critical: CLI package version is never updated before publishing.
The step name claims to update both "CLI types dependency and version", but the jq command only updates the types dependency. The CLI's own version field in apps/cli/package.json is never set to $VERSION before publishing at line 169.
Apply this diff to fix the CLI version update:
- name: Update CLI types dependency and version
if: steps.check-version.outputs.exists == 'false'
run: |
VERSION="${{ steps.version.outputs.version }}"
cd apps/cli
- jq --arg v "^$VERSION" '.dependencies["@better-t-stack/types"] = $v' package.json > tmp.json && mv tmp.json package.json
+ jq --arg v "$VERSION" --arg dep "^$VERSION" '.version = $v | .dependencies["@better-t-stack/types"] = $dep' package.json > tmp.json && mv tmp.json package.json🤖 Prompt for AI Agents
.github/workflows/release.yaml around lines 146 to 151: the workflow only
updates the @better-t-stack/types dependency in apps/cli/package.json but never
sets the CLI package's own "version" field to the release $VERSION; modify the
step to set both .version and .dependencies["@better-t-stack/types"] using jq
(assign .version = $VERSION and update the dependency) and write the output to a
tmp.json then mv tmp.json package.json so the CLI package.json contains the
correct version before publishing.
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.